package Framework;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


import javax.swing.JComponent;

import Framework.*;



public class btn_TopButtons extends pnl_Ancestor implements ActionListener {
	static String CLASS = "btn_TopButtons";
	
	String is_Title; // Title of the window
	
	JLabel lbl_Title;
	
	btn_Ancestor btn_Back = new btn_Ancestor("Back");
	btn_Ancestor btn_Home = new btn_Ancestor("Home");
	
	
	public btn_TopButtons(String as_Title){
		super();
		String METHOD = "btn_TopButtons()";
		debugMessage.log(CLASS + "." + METHOD + " Called.", 10);
		
		
		this.setLayout(null);
		this.setSize(800, ConfigOpts.SIZE_TOPBAR_HEIGHT);
		
		is_Title = as_Title;
		lbl_Title = new JLabel(as_Title, JLabel.CENTER);
		
		this.setBackground(Color.BLACK);
		
		btn_Back.addActionListener(this);
		btn_Home.addActionListener(this);
		btn_Back.setBounds(0,0,100,ConfigOpts.SIZE_TOPBAR_HEIGHT);
		lbl_Title.setBounds(100, 0, 600, ConfigOpts.SIZE_TOPBAR_HEIGHT);;
		btn_Home.setBounds(700, 0, 100, ConfigOpts.SIZE_TOPBAR_HEIGHT);
	
		this.add(btn_Back);
		this.add(lbl_Title);
		this.add(btn_Home);
		this.setBackgroundImage(ConfigOpts.IMAGE_BACKGROUND_TOPBUTTONS);
		this.setBounds(0, 0, 800, ConfigOpts.SIZE_TOPBAR_HEIGHT);;
		//lbl_Title.setText(ConfigOpts.SIZE_TEXT_LARGE);
		//lbl_Title.getFontName();
		System.out.println(lbl_Title.getFont().getFontName());
		debugMessage.log(CLASS + "." + METHOD + " Finished.", 10);
		
	}
	
	public void actionPerformed(ActionEvent e) {
		String METHOD = "actionPerformed()";
		debugMessage.log(CLASS + "." + METHOD + " Called.", 11);
		
		// Typecasting windows here really shouldn't matter unless you go and do something silly like
		// Attempt to actually use a standard JFrame.
		
		if (e.getSource().equals(btn_Home)){
			((pnl_Ancestor) ((JComponent) e.getSource()).getRootPane().getContentPane()).goHome();
		} else if (e.getSource().equals(btn_Back)) {
			System.out.println("Trying to escape this shit.");
			((pnl_Ancestor) ((JComponent) e.getSource()).getRootPane().getContentPane()).goBack();
		}
		debugMessage.log(CLASS + "." + METHOD + " Finished.", 11);
	}
}
